<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const arr1 = [1, 3, 5, 7, 9, 0];
    const arr2 = [2, 3, 5, 8, 0];



    function fn(arr1, arr2) {
      return arr1.reduce((p, c) => {
        return arr2.includes(c) ? [...p, c] : p;
      }, []);
    }

    const result = fn(arr1, arr2);
    console.log(result);
  </script>
</body>

</html>